package com.heima.admin.controller.v1;

import com.heima.admin.service.SensitiveService;
import com.heima.model.admin.dto.SensitiveDTO;
import com.heima.model.admin.pojo.AdSensitive;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词管理controller",tags = "敏感词管理controller")
public class sensitiveController {
    @Autowired
    private SensitiveService sensitiveService;

    @PostMapping("/list")
    public PageResponseResult getSensitiveList(@RequestBody SensitiveDTO dto){
        return  sensitiveService.sensitiveList(dto);
    }


    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody SensitiveDTO dto){
        return  sensitiveService.saveSensitive(dto);
    }

    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody AdSensitive sensitive){
        return  sensitiveService.updateSensitive(sensitive);
    }

    @DeleteMapping("/del/{id}")
    public ResponseResult deleteSensitive(@PathVariable("id") Integer id){
        return  sensitiveService.deleteSensitive(id);
    }
    //"/api/v1/sensitive")
    @ApiOperation(value = "查询敏感词的集合")
    @PostMapping("/sensitives")
    public ResponseResult findSensitiveList(){
        return sensitiveService.selectAllSensitives();
    }

}
